package com.scuec.groupfive.service.impl;

import com.scuec.groupfive.entity.Post;
import com.scuec.groupfive.mapper.PostMessageMapper;
import com.scuec.groupfive.service.PostMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;

/**
 * 帖子统计服务实现
 */
@Service
public class PostMessageServiceImpl implements PostMessageService {
    @Autowired
    private PostMessageMapper postMessageMapper;

    @Override
    public int getTotalMessageCount() {
        return postMessageMapper.getTotalMessageCount();
    }

    @Override
    public int getMessageCountByDateRange(Date startDate, Date endDate) {
        // 结束日期设置为当天的23:59:59
        endDate = new Date(endDate.getTime() + 24 * 60 * 60 * 1000 - 1);
        return postMessageMapper.getMessageCountByDateRange(startDate, endDate);
    }
}